home *** CD-ROM | disk | FTP | other *** search
Text File | 1988-06-23 | 3.4 KB | 144 lines | [TEXT/MPS ] |
- (* This is an FKEY that empties the content region of all
- the windows in a layer. This is useful under MultiFinder
- because you can select icons that might be covered up,
- once all the windows above it become "transparent".
-
- It is a simple variation of the technique described by Greg
- Marriott in the Oct 87 MacTutor. It works by modifying
- the strucRgn and contRgn of all the windows, which is a very
- bad thing to do, especially under MultiFinder (where this
- FKEY is most useful. This puts the FKEY into the category of
- extra-slimey hacks.
-
- The basic routines can be recombined to achieve a variety
- of effects. (For example, instead of toggling, one FKey
- could make the windows transparent and another restore them.
-
- Note that we do no error checking on the region calculations,
- so we could crash in low memory situations.
-
-
- Known Bugs:
- • In MPW if you activate a transparent window, the shell
- computes the active region of the window. Since the window
- is transparent, the region is empty. If you make the window
- normal, the shell becomes confused until the window is activated
- again.
-
-
- MPW Build commands (to make FKEY 9):
-
- Pascal Holey.p -o Holey.p.o
- link Holey.p.o -o 'Holey FKEY' -rt FKEY=9 -sn Main="Holey" ∂
- -m 'ENTRYPOINT' -t 'FKEY' -c 'FKEY'
-
- Larry Rosenstein
- *)
-
- UNIT Holey;
-
- INTERFACE
-
- USES
- MemTypes, Quickdraw, OSIntf, ToolIntf;
-
- PROCEDURE EntryPoint;
-
- IMPLEMENTATION
-
- PROCEDURE HoleyFKey; FORWARD;
-
- { The main program. We need this entry point here because
- we use nested procedures. Otherwise the nested procs
- would be first in the segment. }
- PROCEDURE EntryPoint;
- BEGIN
- HoleyFKey;
- END;
-
- PROCEDURE HoleyFKey;
-
- VAR w: WindowPeek;
- v: INTEGER;
-
- savePort: GrafPtr;
-
- topChange: WindowPeek; { topmost windows that changed }
- clobber: RgnHandle; { union of all changed windows }
-
- PROCEDURE Setup; { call this to setup things }
- BEGIN
- { Save the current port }
- GetPort(savePort);
-
- { Init some variables }
- topChange := NIL;
- clobber := NewRgn;
- END;
-
- PROCEDURE WrapUp; { call this after munging the windows }
- BEGIN
- IF topChange <> NIL THEN { have system refresh things }
- BEGIN
- CalcVisBehind(topChange, clobber); { cause update events }
- PaintBehind(topChange, clobber); { refresh window structures }
- END;
-
- DisposeRgn(clobber);
-
- SetPort(savePort);
- END;
-
- PROCEDURE NoteWindow(w: WindowPeek); { remember info about window }
- BEGIN
- IF topChange = NIL THEN
- topChange := w;
-
- UnionRgn(clobber, w^.strucRgn, clobber);
- END;
-
- PROCEDURE MakeTransparent(w: WindowPeek);
- BEGIN
- WITH w^ DO { windows are nonrelocatable }
- IF visible THEN { don't call this on invisible windows }
- BEGIN
- NoteWindow(w);
-
- { make content rgn empty and fix structure rgn accordingly }
- DiffRgn(strucRgn, contRgn, strucRgn);
- SetEmptyRgn(contRgn);
- END;
- END;
-
- PROCEDURE MakeNormal(w: WindowPeek);
- BEGIN
- IF w^.visible THEN { don't call this on invisible windows }
- BEGIN
- WITH grafPtr(w)^.portRect DO
- SizeWindow(windowPtr(w), right-left, bottom-top, TRUE);
- NoteWindow(w);
- END;
- END;
-
-
- BEGIN
- Setup;
-
- w := WindowPeek(FrontWindow);
-
- { Loop through all the windows }
- WHILE w <> NIL DO
- BEGIN
- IF EmptyRgn(w^.contRgn) THEN { already transparent }
- MakeNormal(w)
- ELSE { window is normal }
- MakeTransparent(w);
-
- w := w^.nextWindow;
- END;
-
- WrapUp;
- END;
-
- END.
-